RenameController = $.Controller.extend('rename', {
	submit : function(params){
		params.event.kill();
		var form = params.element ;
		var from_path = $F('RENAME_FORM_PATH');
		var to_new_name = $F('RENAME_FORM_NEW_NAME');
		var dirs = from_path.split('/');
		dirs[dirs.length-1]= to_new_name;
		var to_path = dirs.join('/');
		form.innerHTML = 'Renaming ...';
		form.style.color = 'Gray';

		if(MVC.$E(from_path).className.startsWith('file'))
			new MVC.Ajax('/ftp/rename_file?from_path='+encodeURIComponent(from_path)+'&to_path='+encodeURIComponent(to_path), 
			{onSuccess: this.continue_to('renamed_file'), asynchronous:true, evalScripts:false});
		else
			new MVC.Ajax('/ftp/rename_folder?from_path='+encodeURIComponent(from_path)+'&to_path='+encodeURIComponent(to_path), 
			{onSuccess: this.continue_to('renamed_folder'), asynchronous:true, evalScripts:false});
		
		
		return false;
	},
	renamed_folder : function(response){
		eval('var object = '+response.responseText);
		if(object.response != 'Renamed Folder'){  alert(object.response);return;}
		DirectoryView.rename(object);
	},
	renamed_file : function(response){
		eval('var object = '+response.responseText);
		if(object.response != 'Renamed File'){  alert(object.response);return;}
		MVC.$E(object.from_path).remove(); 
		f= new MVC.JFile(object.to_path);
		editAreaLoader.getRenameFile('EDITAREA_TEXTAREA', object.from_path, object.to_path, f.file_and_extension());
		DirectoryView.update(object);
	},
	load : function(params){
		
	},
	"input blur" :function(params){
		
	},
	"input click" : function(params){
		params.event.kill();
	}
});